package com.example.zhaojianxu.signin.bank.number

import android.os.Bundle
import android.view.View
import com.example.zhaojianxu.signin.R
import com.example.zhaojianxu.signin.bank.http.NumberEntity
import com.example.zhaojianxu.signin.bean.BaseActivity
import com.example.zhaojianxu.signin.common.constance.ComConstance
import com.example.zhaojianxu.signin.common.http.HttpUtil
import kotlinx.android.synthetic.main.activity_number.*
import kotlinx.android.synthetic.main.common_title_bar.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class NumberActivity : BaseActivity() {

    override fun initView() {
        common_title.text = "叫号"
        common_setting.visibility = View.GONE
        common_back.setOnClickListener {
            finish()
        }
    }

    override fun initData() {
        HttpUtil.instance.getBankApi()?.postQueryNumber(ComConstance.UID)?.enqueue(object: Callback<NumberEntity>{
            override fun onFailure(call: Call<NumberEntity>, t: Throwable) {

            }

            override fun onResponse(call: Call<NumberEntity>, response: Response<NumberEntity>) {
                if (response.isSuccessful && response.body() != null){
                    activity_number_2.text = response.body()?.now.toString()
                    activity_number_4.text = response.body()?.bank.toString()
                    activity_number_6.text = response.body()?.number.toString()
                }
            }

        })
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_number)
    }
}
